package 剑指Offer.easy;

import java.util.Deque;
import java.util.LinkedList;

public class 对称的二叉树 {

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    class Solution {
        public boolean isSymmetric(TreeNode root) {
            if (root == null) {
                return false;
            }
            return recursion(root.left, root.right);
        }

        private boolean recursion(TreeNode L, TreeNode R) {
            if (L == null && R == null) {
                return true;
            }
            if (L == null || R == null || L.val != R.val) {
                return false;
            }
            //以上条件不满足，说明两个结点值相等，下面判断其左右结点
            return recursion(L.left, R.right) && recursion(L.right, R.left);
        }
    }
}
